package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.ShoppingMapper;
import com.jt.pojo.Cart;
import com.jt.pojo.Shopping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartServiceImpl  implements CartService{
    @Autowired
    private ShoppingMapper shoppingMapper;
    //添加购物车
    @Override
    public void addCart(Cart cart) {

    }
    //查询购物车
    @Override
    public List<Shopping> findCart(Integer id) {
        return shoppingMapper.selectList(new QueryWrapper<Shopping>()
                .eq("parent_id", id)
        );
    }

    @Override
    public void updateCart(Integer id, Integer nummer) {

    }

    //减少购物车中的商品数量
    @Override
    public void decreaseCart(Shopping shopping) {
        shoppingMapper.decreasenummer(shopping.getId());
    }
    //增加购物车中的商品数量
    @Override
    public void addCart(Shopping shopping) {
        shoppingMapper.addnummer(shopping.getId());
    }
    //删除购物车
    @Override
    public void deleteCart(Integer id) {
        shoppingMapper.deletenummer(id);
    }

    @Override
    public void deleteAllCart(Integer id) {
        shoppingMapper.deleteAllCart(id);
    }


}
